#include "dag.h"

#include <string>
#include <set>

using namespace dag;
using namespace std;


DagError::DagError(const string& msg)
:	m_What(msg) {
}

DagError::~DagError() throw() {
}

const string& DagError::what() const throw() {
	return m_What;
}

NullPtr::NullPtr()
:	DagError("null pointer")
{
}

NullPtr::~NullPtr() throw() {
}

InvalidArgument::InvalidArgument()
:	DagError("invalid argument")
{
}

InvalidArgument::~InvalidArgument() throw() {
}

NodeStateError::NodeStateError() 
:	DagError("node state error")
{
}

NodeStateError::~NodeStateError() throw() {
}

SerialError::SerialError(const string& msg) 
:	DagError(msg)
{
}

SerialError::~SerialError() throw() {
}

InvalidValue::InvalidValue() 
:	SerialError("invalid value")
{
}

InvalidValue::~InvalidValue() throw() {
}

InvalidFrameOpId::InvalidFrameOpId()
:	SerialError("invalid frame op id")
{
}

InvalidFrameOpId::~InvalidFrameOpId() throw() {
}

InvalidToken::InvalidToken(const string& expectedToken,
						   const string& foundToken)
:	SerialError("invalid token"),
	m_Expected(expectedToken),
	m_Found(foundToken) 
{
}

InvalidToken::~InvalidToken() throw() {
}
	
const string& InvalidToken::expected() const {
	return m_Expected;
}

const string& InvalidToken::found() const {
	return m_Found;
}


FileError::FileError(const string& msg, const string& filename)
:	SerialError(msg),
	m_Filename(filename)
{
}

FileError::~FileError() throw() {
}
	
const string& FileError::file() const throw() {
	return m_Filename;
}


FileWriteError::FileWriteError(const string& filename)
:	FileError("file write error", filename)
{
}

FileWriteError::~FileWriteError() throw() {
}


FileReadError::FileReadError(const string& filename)
:	FileError("file read error", filename)
{
}

FileReadError::~FileReadError() throw() {
}


UnequalFrameSpec::UnequalFrameSpec(const FrameSpec& spec1, 
								   const FrameSpec& spec2) 
:	DagError("unequal frame spec"),
	m_Spec1(spec1),
	m_Spec2(spec2)
{
}

UnequalFrameSpec::~UnequalFrameSpec() throw() {
}
	
const FrameSpec& UnequalFrameSpec::frameSpec1() const {
	return m_Spec1;
}

const FrameSpec& UnequalFrameSpec::frameSpec2() const {
	return m_Spec2;
}

GraphError::GraphError(const string& msg, 
					   const Node* node, 
					   const set<const Node*>& nodes,
					   const vector<Edge*>& edges,
					   const FrameSpec& spec,
					   GraphErrorType errorType)
:	DagError(msg),
	m_Node(node),
	m_Nodes(nodes),
	m_Edges(edges),
	m_FrameSpec(spec),
	m_ErrorType(errorType)
{
}
	
GraphError::~GraphError() throw() {
}
	
const Node* GraphError::getNode() const throw() {
	return m_Node;
}

const set<const Node*>& GraphError::getNodes() const throw() {
	return m_Nodes;
}

const vector<Edge*>& GraphError::getEdges() const throw() {
	return m_Edges;
}

const FrameSpec& GraphError::spec() const throw() {
	return m_FrameSpec;
}

GraphErrorType GraphError::getGraphErrorType() const throw() {
	return m_ErrorType;
}
	

NonInvertibleNode::NonInvertibleNode(const Node* node)
:	GraphError("non-invertible node", 
			   node, 
			   set<const Node*>(), 
			   vector<Edge*>(), 
			   FrameSpec(),
			   GraphError_NonInvertibleNode)
{
}

NonInvertibleNode::~NonInvertibleNode() throw() {
}

LoopError::LoopError(const set<const Node*>& nodes)
:	GraphError("loop in graph",
			   NULL,
			   nodes,
			   vector<Edge*>(),
			   FrameSpec(),
			   GraphError_LoopInGraph)
{
}

LoopError::~LoopError() throw() {
}

MissingHeadNode::MissingHeadNode()
:	GraphError("missing head node",
			   NULL,
			   set<const Node*>(),
			   vector<Edge*>(),
			   FrameSpec(),
			   GraphError_MissingHeadNode)
{
}

MissingHeadNode::~MissingHeadNode() throw() {
}

MissingTailNode::MissingTailNode() 
:	GraphError("missing tail node", 
			   NULL, 
			   set<const Node*>(), 
			   vector<Edge*>(), 
			   FrameSpec(),
			   GraphError_MissingTailNode)
{
}

MissingTailNode::~MissingTailNode() throw() {
}

MissingLearnResource::MissingLearnResource(const string& msg, 
										   const Node* node,
										   GraphErrorType errorType)
:	GraphError(msg,
			   node,
			   set<const Node*>(),
			   vector<Edge*>(),
			   FrameSpec(),
			   errorType)
{
}

MissingLearnResource::~MissingLearnResource() throw() {
}

MissingInputs::MissingInputs(const Node* node) 
:	MissingLearnResource("missing inputs", node, GraphError_MissingInputs)
{
}

MissingInputs::~MissingInputs() throw() {
}

MissingOutputs::MissingOutputs(const Node* node)
:	MissingLearnResource("missing outputs", node, GraphError_MissingOutputs)
{
}

MissingOutputs::~MissingOutputs() throw() {
}

MissingInputsAndOutputs::MissingInputsAndOutputs(const Node* node)
:	MissingLearnResource("missing inputs and outputs", 
						 node, 
						 GraphError_MissingInputsAndOutputs)
{
}

MissingInputsAndOutputs::~MissingInputsAndOutputs() throw() {
}

UnconnectedNode::UnconnectedNode(const Node* node)
:	GraphError("unconnected node",
			   node,
			   set<const Node*>(), 
			   vector<Edge*>(),
			   FrameSpec(),
			   GraphError_UnconnectedNode)
{
}

UnconnectedNode::~UnconnectedNode() throw() {
}

AmbiguousConnection::AmbiguousConnection(const vector<Edge*>& edgeVec)
:	GraphError("ambiguous link",
			   NULL, 
			   set<const Node*>(),
			   edgeVec, 
			   FrameSpec(),
			   GraphError_AmbiguousConnection)
{
}

AmbiguousConnection::~AmbiguousConnection() throw() {
}

HangingConnection::HangingConnection(const Node* node,
									 const vector<Edge*>& edgeVec)
:	GraphError("hanging link",
			   node,
			   set<const Node*>(),
			   edgeVec,
			   FrameSpec(),
			   GraphError_HangingConnection)
{
}

HangingConnection::~HangingConnection() throw() {
}
//
//IncompatibleFrameSpec::IncompatibleFrameSpec(const vector<Edge*>& edgeVec,
//											 const Node* node,
//											 const FrameSpec& spec)
//:	GraphError("incompatible frame spec",
//			   node,
//			   set<const Node*>(),
//			   edgeVec,
//			   spec,
//			   GraphError_IncompatibleFrameSpec)
//{
//}
//
//IncompatibleFrameSpec::~IncompatibleFrameSpec() throw() {
//}

